package com.diaohaiwen.basic.websockt.controller;

import com.diaohaiwen.basic.websockt.obj.dto.FileDto;
import com.diaohaiwen.basic.websockt.obj.dto.TextDto;
import com.diaohaiwen.basic.websockt.obj.vo.NoticeVo;
import com.diaohaiwen.basic.websockt.service.NoticeService;
import com.diaohaiwen.common.obj.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author 刁海文
 * @since 2023/12/7 22:39
 */
@RestController
@RequestMapping("/notice")
public class NoticeController {
    @Resource
    NoticeService noticeService;

    @PostMapping("/text")
    public Result<NoticeVo> text(@RequestBody TextDto text) {
        return Result.success(noticeService.text(text));
    }

    @PostMapping("/file")
    public Result<NoticeVo> file(FileDto receiver, MultipartFile file) throws IOException {
        return Result.success(noticeService.file(receiver,file));
    }
}
